package com.linchong.concurrency.chapter4;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author:linchong
 * @CreateTime:2020-01-03 14:31
 * @Description: 1.子线程设置守护线程，测试
 */
@Slf4j
public class DaemonThread2 {
	public static void main(String[] args) {
		Thread t = new Thread(() -> {
			Thread innerThread = new Thread(() -> {
				try {
					while (true) {
						log.info("do something for health check.");
						Thread.sleep(1_000);
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			});
			innerThread.setDaemon(true);
			innerThread.start();
			try {
				Thread.sleep(1_000);
				log.info("t thread finished.");
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		});
		/**t.setDaemon(true);**/
		t.start();

	}
}
